package com.gable.report.thread;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * Created by gable on 2018/5/11.
 */
public class RedisValueStoreThread implements Runnable{

    private static final Log logger = LogFactory.getLog(RedisValueStoreThread.class);

    private RedisTemplate redisTemplate;

    private String key;

    private Object object;

    public RedisValueStoreThread(RedisTemplate redisTemplate, String key, Object object) {
        this.redisTemplate = redisTemplate;
        this.key = key;
        this.object = object;
    }


    @Override
    public void run() {
        try {
            BoundValueOperations valueOperations = redisTemplate.boundValueOps(key);
            valueOperations.set(object);
        } catch (Exception e) {
            e.printStackTrace();
            logger.info("----------redis服务异常-----------");
        }
    }
}
